﻿#include "chartthread.h"

ChartThread::ChartThread(QObject *parent) : QObject(parent)
{
    m_worker = new ChartWorker();
    m_worker->moveToThread(&m_workThread);
    connect(this, &ChartThread::sigInitialize, m_worker, &ChartWorker::Initialize);
    connect(this, &ChartThread::sigStart, m_worker, &ChartWorker::start);
    connect(this, &ChartThread::sigStop, m_worker, &ChartWorker::stop);
    connect(&m_workThread, &QThread::finished, m_worker, &QObject::deleteLater);
}

ChartThread::~ChartThread()
{
}

void ChartThread::Initialize()
{
    emit sigInitialize();
}

void ChartThread::start(QString file)
{
	m_worker->m_deal.m_bDiscontinue = false;
	m_worker->m_deal.m_db.m_bDiscontinue = false;
    m_workThread.start();
    emit sigStart(file);
}

void ChartThread::stop()
{
    m_worker->m_deal.m_bDiscontinue = true;
    m_worker->m_deal.m_db.m_bDiscontinue = true;
}

void ChartThread::Terminate()
{
    m_workThread.quit();
    m_workThread.wait();
}
